#pragma once

#include <pthread.h>

class lock
{
public:
    lock(pthread_mutex_t* lock)
        :_lock(lock)
    { }

    pthread_mutex_t* getlock()
    {
        return _lock;
    }

private:
    pthread_mutex_t* _lock;
};

class lockguard
{
public:
    lockguard(lock* lock)
        :_lock(lock)
    {
        pthread_mutex_lock(_lock->getlock());
    }

    ~lockguard()
    {
        pthread_mutex_unlock(_lock->getlock());
    }

private:
    lock* _lock;
};